<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='./vue.global.js'></script>
</head>

<body>
    <div id='app'>
        {{slotname}}
        <todo-list>
            <!-- <template v-slot:s1>
                这里给s1
            </template> -->
            <template v-slot:[slotname]>
                这里给s1
            </template>

            <!-- <template v-slot:s2> -->
            <template #s2>
                这里给s2
            </template>
        </todo-list>
        <hr>

    </div>

    <script>
        const app = Vue.createApp({
            data() {
                return {
                    count: 0,
                    item: "多拉克",
                    slotname:"s1"
                }
            }
        })

        app.component(
            "todo-list",
            {
                template: `
                <ul>
                    <li v-for="( item, index ) in items">
                        <!--{item,index} slotProps -->
                        <slot :item="item" :index="index" name="s1"></slot>
                        <slot :item="item" :index="index" name="s2"></slot>
                    </li>
                </ul>
                `,
                data() {
                    return {
                        items: ['Feed a cat', 'Buy milk',undefined]
                    }
                },
            }
        )
        const vm = app.mount('#app')
    </script>
</body>

</html>